package com.top.application;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.google.common.base.Predicates;

import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
public class Swagger2 {
	
	@Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.top.application.controller"))
                .paths(Predicates.or(
                        PathSelectors.ant("/oauth/*"),PathSelectors.ant("/api/*")
                                    ))
                .build();
    }

	private ApiInfo apiInfo() {// 创建API的基本信息，这些信息会在Swagger UI中进行显示  
        return new ApiInfoBuilder()  
                .title("上海拓攻机器人有限公司-用户服务-RESTful APIs")// API 标题  
                .description("用户信息微服务 RESTful APIs")// API描述  
                .description("用户注册页面如下：")
                .description("http://114.55.73.147:18060/registerPage")
                .description("客户端注册页面如下：")
                .description("http://114.55.73.147:18060/client/registerPage")
                .version("1.0")// 版本号  
                .build();  
    } 
}
